package console;

import java.util.Scanner;
import defaultPackage.*;
public class console extends Thread 
{
	private static Scanner in = new Scanner(System.in);
	MainClass main;
	Command[] commands = new Command[3];
	public console(MainClass main)
	{
		this.main = main;
		commands[0] = new Addresources();
		commands[1] = new Help(this);
		commands[2] = new Debug(main);
	}
	public void run()
	{
		System.out.println("type help to see command's");
		while(true)
		{
			String[] input = prompt(">");
			String com = input[0];                         //com is command
			String args[] = new String[input.length-1];
			for(int i = 1;i<input.length;i++)	args[i-1] = input[i];
			for(Command command:commands)
			{
				if(command.check(com))	command.run(args);
			}
		}
	}
	public static String[] prompt(String out)
	{
		String input = null;
		while(input == null)
		{
		System.out.print(out);
		input = in.nextLine().trim().toLowerCase();
		}
		return input.split(" ");
	}
}
